
$(function () {
    // 初始化日期选择控件
    $('.date-input').datepicker({
        language: "zh-CN",
        autoclose: true,
        clearBtn: true,
        todayHighlight: true,
        format: "yyyy-mm-dd"
    });
});


/**
 * 点击客户姓名跳转客户详情页面
 * @param value
 * @param row
 * @param index
 * @returns {string}
 */
function customerNameFormat(value, row, index) {
    return '<a style="color:#ff3300;cursor:pointer;text-decoration:underline;" target="_blank"  onclick=\'customerDetail(\"' + row.customerId + '")\'>' + value + '</a>';
}

function customerDetail(customerId) {
    parent.$(parent.document).data('multitabs').create({
        iframe: true,
        title: '客户详情',
        url: "/front/customerManager/customerDetail?customerId=" + customerId
    }, true);
}

/**
 * 点击联系人姓名跳转联系人详情页面
 * @param value
 * @param row
 * @param index
 * @returns {string}
 */
function contactNameFormat(value, row, index) {
    return '<a style="color:#ff0000;cursor:pointer;text-decoration:underline;" target="_blank"  onclick=\'contactDetail(\"' + row.contactPersonId + '")\'>' + value + '</a>';
}

function contactDetail(contactId) {
    parent.$(parent.document).data('multitabs').create({
        iframe: true,
        title: '联系人详情',
        url: "/front/contactManager/contactDetail?contactId=" + contactId
    }, true);
}


/**


 /**
 * 时间转换
 * @param value
 * @param row
 * @param index
 * @returns {string}
 */
function dateFormat(value, row, index) {
    if (value != null) {
        var date = new Date(value);
        var month = date.getMonth() + 1;
        var tian = date.getDate();
        if (month >= 1 && month <= 9) {
            month = "0" + month;
        }
        if (tian >= 1 && tian <= 9) {
            tian = "0" + tian;
        }

        return date.getFullYear() + '-' + month + '-' + tian;
    }
}



